package com.polaris.live.viewmodel

import androidx.lifecycle.MutableLiveData
import com.polaris.live.common.mvvm.viewmodel.BaseViewModel
import com.polaris.live.common.network.request
import com.polaris.live.common.network.state.ResultState
import com.polaris.live.net.userService
import com.polaris.live.resp.back_resp.ListResultUserInviteRewardResp
import com.polaris.live.resp.base.ListResp
import com.polaris.live.widget.refresh.OnListListener

/**
 * InviteFriendViewModel
 *
 * @author Created by 半仙 on 2024/4/10/010 15:31
 */
class InviteRewardViewModel : BaseViewModel(), OnListListener {

    private val pageSize = 20
    val inviteBeRewardsLiveData =
        MutableLiveData<ResultState<ListResp<ListResultUserInviteRewardResp>>>()

    private fun getMyInvite(
        pageNumber: Int,
        pageSize: Int = this.pageSize,
    ) {
        request({ userService.getInviteBeRewards(pageNumber, pageSize) }, inviteBeRewardsLiveData)
    }

    override fun onRefresh() {
        getMyInvite(0)
    }

    override fun onLoadMore(pageIndex: Int) {
        getMyInvite(pageIndex)
    }
}